
#pragma once

#define UDPCALLBENCH_WAIT_RESPONSE_SECONDS 3

class UdpCallBenchMgr : public asyframe::ActorMgrBase
{
public:
	UdpCallBenchMgr(boost::shared_ptr<boost::asio::ip::udp::endpoint> _pRemoteEndpoint, std::size_t _workerPoolSize = 1);
	virtual ~UdpCallBenchMgr();

	virtual retT start();

protected:
	boost::shared_ptr<boost::asio::ip::udp::endpoint> pRemoteEndpoint_;
};

class UdpCallBenchActor : public asyframe::ActorBase, public virtual asyframe::IUdpAction
{
public:
	UdpCallBenchActor(int _index);
	virtual ~UdpCallBenchActor();

	virtual retT init();

	virtual retT start();

	virtual retT close();

	void setRemoteEndpoint(boost::shared_ptr<boost::asio::ip::udp::endpoint> _pRemoteEndpoint);

	retT sendOneRequest(bool isInit = false);

	retT onReadStoreAnsResponse( std::string _resourceKey, boost::shared_ptr<asyframe::UdpHandlerContext> _pUdpHandlerContext, std::size_t _bytesTransferred, const boost::system::error_code& e, std::size_t _timeoutCount);

	retT onReadFetchAnsResponse( boost::shared_ptr<asyframe::UdpHandlerContext> _pUdpHandlerContext, std::size_t _bytesTransferred, const boost::system::error_code& e, std::size_t _timeoutCount);

protected:
	boost::shared_ptr<asyframe::UdpHandler> pUdpHandler_;
	boost::shared_ptr<boost::asio::ip::udp::endpoint> pRemoteEndpoint_;
	int seed_;
	int success_;
	int fail_;
	int timeout_;
	int error_;
	int index_;
};
